<?php require_once('../../Connections/agriculture.php'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>留言板登陆</title>
</head>

<body>

<?php
if($_POST['user']){
$poster=$_POST['user'];
$pass=$_POST['pass'];

//检查登陆账号和密码是否正确
mysql_select_db($database_agriculture, $agriculture);
$checkSql="select * from poster where poster_user='".$poster."' and poster_pass='".$pass."'";
$checkResult=mysql_query($checkSql,$agriculture);
$row_checkResultRecordset=mysql_fetch_assoc($checkResult);

//如果登陆信息正确,则显示登陆成功,返回到信息列表,不成功重新登陆
if($row_checkResultRecordset['poster_user']){
$_SESSION['poster']=$row_checkResultRecordset['poster_user'];
echo $_SESSION['poster']."登陆成功!";
echo "<meta http-equiv=refresh content='0; url=expert.php'>";
}else{
echo "错误的账号或密码,请检查输入,重新登陆!";
echo "<meta http-equiv=refresh content='2; url=login.php'>";
}
}else{
echo '<form id="form1" name="form1" method="post" action="">
  <p>账号:
    <label>
    <input name="user" type="text" id="user" />
    </label>
  </p>
  <p>密码: 
    <label>
    <input name="pass" type="password" id="pass" />
    </label>
  </p>
  <p>
    <label>
    <input type="submit" name="Submit" value="登陆" />
    </label>
    <label>
    <input type="reset" name="Submit2" value="重置" />
    </label>
  </p>
</form>
<a href="reg.php">没有账号?点这里注册</a>';
}
?>
</body>
</html>
